<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:f="http://java.sun.com/jsf/core" 
      xmlns:h="http://java.sun.com/jsf/html" 
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:c="http://java.sun.com/jsp/jstl/core"> 
    <h:head>
        <title>Group Buying Item</title>
        <style type="text/css">
            body{
                margin-top: 50px;
                margin-left:150px;
                margin-right:150px;
            }
        </style>
    </h:head>
    <h:body>
        <h:form>
            <p:panel header="#{groupBuyCustManagedBean.selectedItem.name}"
                     style="text-align: center; font-size: larger">
                <h:panelGrid columns="2">
                    <h:panelGrid columns="3" style="text-align: left; border-right: #BBBBBB;
                                 border-right-style: ridge; ">

                        <h:outputLabel for="originalPrice" value="Original Price: "/>
                        <h:outputText id="originalPrice" value="#{groupBuyCustManagedBean.selectedItem.originalPrice}"/>
                        <p:message for="originalPrice"/>


                        <h:outputLabel for="offerPrice" value="Offering Price: "/>
                        <h:outputText id="offerPrice" value="#{groupBuyCustManagedBean.selectedItem.offeredPrice}" />
                        <p:message for="offerPrice"/>

                        <h:outputLabel for="effectiveStart" value="Effective Start Date: "/>
                        <h:outputText id="effectiveStart" value="#{groupBuyCustManagedBean.selectedItem.effectiveStart}" />
                        <p:message for="effectiveStart"/>


                        <h:outputLabel for="effectiveEnd" value="Effective End Date: "/>
                        <h:outputText id="effectiveEnd" value="#{groupBuyCustManagedBean.selectedItem.effectiveEnd}" />
                        <p:message for="effectiveEnd"/>

                        <h:outputLabel for="redemptionStart" value="Redemption Start Date: "/>
                        <h:outputText id="redemptionStart" value="#{groupBuyCustManagedBean.selectedItem.redemptionStart}"/>
                        <p:message for="redemptionStart"/>

                        <h:outputLabel for="redemptionEnd" value="Redemption End Date: "/>
                        <h:outputText id="redemptionEnd" value="#{groupBuyCustManagedBean.selectedItem.redemptionEnd}" />
                        <p:message for="redemptionEnd"/>

                        <h:outputLabel for="minQuota" value="Minimum Quota: "/>
                        <h:outputText id="minQuota" value="#{groupBuyCustManagedBean.selectedItem.minQuota}" />
                        <p:message for="minQuota"/>

                        <h:outputLabel for="maxQuota" value="Maximum Quota: "/>
                        <h:outputText id="maxQuota" value="#{groupBuyCustManagedBean.selectedItem.maxQuota}" />
                        <p:message for="maxQuota"/>

                        <h:outputLabel for="requireBooking" value="Require booking: "/>
                        <h:outputText id="requireBooking" value="#{groupBuyCustManagedBean.selectedItem.requireBooking}"/>
                        <p:message for="requireBooking"/>


                        <h:outputLabel for="validateRequirements" value="Validate Requirements: "/>
                        <h:outputText id="validateRequirements" 
                                      value="#{groupBuyCustManagedBean.selectedItem.validateRequirements}" 
                                      style="width:500px; height:300px"/>
                        <p:message for="validateRequirements"/>


                        <h:outputLabel for="description" value="Description: "/> 
                        <h:outputText id="description" 
                                      value="#{groupBuyCustManagedBean.selectedItem.description}"
                                      style="width:500px; height:300px"/>
                        <p:message for="description"/>

                        <h:outputText value="Select number to buy: "/>
                        <h:selectOneMenu value="#{groupBuyCustManagedBean.numberToBuy}"
                                         style="width:30%">
                            <f:selectItem itemValue=""
                                          itemLabel="Select One Quota"/>
                            <f:selectItems value="#{groupBuyCustManagedBean.computeQuotaSeq()}"/>
                            <p:ajax update="total"
                                    listener="#{groupBuyCustManagedBean.handleNumberToBuyChange()}" /> 
                        </h:selectOneMenu>  
                        <p:ajaxStatus style="width:16px;height:16px;">  
                            <f:facet name="start">  
                                <h:graphicImage value="../design/ajaxloading.gif" />  
                            </f:facet>  

                            <f:facet name="complete">  
                                <h:outputText value="" />  
                            </f:facet>  
                        </p:ajaxStatus> 

                        <h:outputText value="Total Price (SGD): "/>
                        <h:outputText id="total" value="#{groupBuyCustManagedBean.subtotal}"/>

                    </h:panelGrid> 
                </h:panelGrid>  
            </p:panel>
        </h:form>
        
        <form id="id_PaypalForm" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" 
              style="margin-left:auto;margin-right:auto;">  

            <input type="hidden" name="cmd" value="_xclick"/>  
            <input type="hidden" name="business" value="zhou84_1317112812_biz@gmail.com"/>  
            <input type="hidden" name="item_name"   value="Purchase Order"/>  
            <input type="hidden" name="item_number" value="0"/>  
            <input type="hidden" name="amount" value="#{groupBuyCustManagedBean.getSubtotal()}"/>  
            <input type="hidden" name="tax" value="0"/>  
            <input type="hidden" name="quantity" value="1"/>  
            <input type="hidden" name="no_note" value="1"/>  
            <input type="hidden" name="currency_code" value="SGD"/> 
            <input type="hidden" name="return" value="http://localhost:8080/Foodsage-war/paymentcompleted.xhtml"/> 

            <input type="image" name="submit" border="0"
                   src="https://www.paypal.com/en_US/i/btn/btn_buynow_LG.gif"  
                   alt="PayPal - The safer, easier way to pay online"/>  

        </form>  
        <h:form>
            <p:commandButton value="Back" action="CustomerMainPage?faces-redirect=true"/>
        </h:form>

    </h:body>
</html>
